Conversation
* @param {number} connectionString The connection string to be parsed. | ||
* @return {object} The query string object. | ||
*/ | ||
ConnectionStringParser.parse = function (connectionString) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it works, but it feels really weird to see assignment to a property of a variable before that variable has been defined. Could you move the definition of the constructor function up above the definitions of the methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this some more, I don't see any reason for this to be a "static member" of ConnectionStringParser - just make it a top level function in the module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's 1 reason... styling. Makes it more coherent with other languages and modules.
Is there a bug# for this work? |
*/ | ||
ConnectionStringParser.prototype._parse = function () { | ||
var self = this; | ||
var parts = this._connectionString.split(';'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if there's an escaped ';' or one inside a quoted block? Is this possible? If so, you'll need to handle this differently.
…-sdk-for-node into connectionStrings
ConnectionStringParser.prototype._skipOperator = function (operatorChar) { | ||
if (this._value[this._pos] != operatorChar) { | ||
// Character was expected. | ||
throw new Error('Character not expected ' + operatorChar); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tweak error message to "expecting " + operatorChar + " but instead got " + currentChar + " at position " + this._pos.toString()
Or something like that. Please give more information about what's wrong and where it's wrong.
*/ | ||
ConnectionStringParser.prototype._extractString = function (quote) { | ||
var firstPos = this._pos; | ||
while (this._pos < this._value.length && this._value[this._pos] !== quote) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to escape quotes within a quoted string? If so then this needs to be a little more complex to handle that case. If not, you're good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
http://www.connectionstrings.com/articles/show/important-rules-for-connection-strings
"No escape sequences are supported"
Updated. |
}); | ||
|
||
test('parseQuotedValues', function (done) { | ||
var parsedConnectionString = ConnectionStringParser.parse('"test key"=\'value of test\''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice update on the test cases here and below.
ConnectionStringParser.prototype._skipOperator = function (operatorChar) { | ||
if (this._value[this._pos] != operatorChar) { | ||
// Character was expected. | ||
throw new Error('expecting ' + operatorChar + ' but instead got ' + currentChar + ' at position ' + this._pos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no currentChar variable - you should probably define one, or replace with the full expression.
Adding connection string parser.
update hardcoded uri to fwlink
No description provided.